package cn.wink.springcloud.controller;

import cn.wink.springcloud.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author xw
 * @date 2020-05-08 23:43
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderConsulController {

    // private static final String PAYMENT_URL = "http://localhost:8001";
    private static final String PAYMENT_URL = "http://consul-provider-payment";

    @Resource
    private RestTemplate restTemplate;

    @PostMapping("/create")
    public Result create(){
        ResponseEntity<Result> forEntity = restTemplate.getForEntity(PAYMENT_URL + "/payment/get", Result.class);
        return forEntity.getBody();
    }
}
